
import Vue from "vue"
import VueRouter from "vue-router"
Vue.use(VueRouter)

const mode = "history"

const routes = [
	{
		path: "/",
		component: resolve => require(['../views/home.vue'], resolve),
		children:[
			{
				path: "/",  //ip
				meta:{index:1},
				component: resolve => require(['../views/home-index.vue'], resolve),
			},

			{
				path:"/buddhism_music", //ip/buddhism_music  佛教影音
				meta:{index:1},
				component: resolve => require(['../views/buddhism_music.vue'], resolve)
			},

			{
				path:"/pray", //ip/pray  供奉祈福
				meta:{index:1},
				component: resolve => require(['../views/pray.vue'], resolve)
			}
		]
	},

	{
		path: "/article_details",
		meta:{index:3},
		component: resolve => require(['../views/article_details.vue'], resolve),
	},
	
	{
		path:"/article_serach",
		meta:{index:2},
		component: resolve => require(['../views/article_serach.vue'], resolve)
	},

	{
		path:"/song_list",
		meta:{index:2},
		component: resolve => require(['../views/song_list.vue'], resolve)
	},

	{
		path:"/song_serach",
		meta:{index:3},
		component: resolve => require(['../views/song_serach.vue'], resolve)
	},

	{
		path:"/music_pay",
		meta:{index:4},
		component: resolve => require(['../views/music_pay.vue'], resolve)
	},

	{
		path:"/seek_master_details",
		meta:{index:4},
		component: resolve => require(['../views/seek_master_details.vue'], resolve)
	},

	{
		path:"/seek_master_search",
		meta:{index:3},
		component: resolve => require(['../views/seek_master_search.vue'], resolve)
	},
	{
		path:"/buddhism_music_search",
		meta:{index:2},
		component: resolve => require(['../views/buddhism_music_search.vue'], resolve)
	},

	{
		path:"/seek_master_list",
		meta:{index:2},
		component: resolve => require(['../views/seek_master_list.vue'], resolve)
	},



	{
		path:"/mage_serach",
		meta:{index:2},
		component: resolve => require(['../views/mage_serach.vue'], resolve)
	},

	{
		path:"/pray_details",
		meta:{index:3},
		component: resolve => require(['../views/pray_details.vue'], resolve)
	},

	{
		path:"/pray_search",
		meta:{index:2},
		component: resolve => require(['../views/pray_search.vue'], resolve)
	},

	
	{
		path:"/article_set",
		meta:{index:2},
		component: resolve => require(['../views/article_set.vue'], resolve)
	}
	// seek_master_list
]

// 增强原方法：isBack作为标识来记录前进后退
VueRouter.prototype.go = function () {
	this.isBack = true
	window.history.go(-1)
}

export default new VueRouter({
	mode,
	routes,
	scrollBehavior(to, from, savedPosition) {
		if (savedPosition) {
			return savedPosition
		} else {
			if (from.meta.keepAlive) {
				from.meta.savedPosition = document.body.scrollTop
			}
			return { x: 0, y: to.meta.savedPosition || 0 }
		}
		
		return {
			y: 0
		}
	}
})